package com.knowledge.utils;

import com.knowledge.dao.entity.SysUser;

/**
 * @author zzz
 * @create 2022-02-11 17:52
 *
 * Threadlocal用于用于登陆验证中存取数据 且可以避免线程安全问题
 */
public class UserThreadLocal {
    private UserThreadLocal(){

    }
    //线程变量隔离
    private static final ThreadLocal<SysUser> LOCAL = new ThreadLocal<>();

    public static void put(SysUser sysUser){
        LOCAL.set(sysUser);
    }

    public static SysUser get(){
        return LOCAL.get();
    }
    public static void remove(){
        LOCAL.remove();
    }
}
